package com.example.sys.org.dao;

import com.example.core.dao.BaseDao;
import com.example.sys.org.po.SysRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysRoleDao extends BaseDao<SysRole> {

    @Select("select * from sys_role where id in (select role_id from sys_user_role where user_id = #{userId})")
    public List<SysRole> getRoleByUserId(@Param("userId") String userId);

    @Select("select code from sys_role where id in (select role_id from sys_user_role where user_id = #{userId})")
    public List<String> getRoleCodeByUserId(@Param("userId") String userId);

    @Select("select id from sys_role where id in (select role_id from sys_user_role where user_id = #{userId})")
    public List<String> getRoleIdListByUserId(@Param("userId") String userId);

    @Select("select * from sys_role where code = #{code}")
    public List<SysRole> getRoleListByCode(@Param("code") String code);

    @Select("select * from sys_role where code = #{code}")
    public SysRole getRoleByCode(@Param("code") String code);

    @Select("select * from sys_role where opened = 1")
    public List<SysRole> getRoleOpened();
}
